package me.zhengjie.modules.worth.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import me.zhengjie.base.CommonModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Date;
import java.sql.Timestamp;

/**
* @author lida
* @date 2022-05-01
*/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("personal_capital")
public class Capital extends CommonModel<Capital> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "资产id")
    @TableId(type= IdType.ASSIGN_ID)
    private String id;

    private String username;

    @ApiModelProperty(value = "名称")
    @NotBlank
    private String title;

    @ApiModelProperty(value = "资产类型")
    @NotBlank
    private String purchasetype;

    @ApiModelProperty(value = "购置金额")
    private String purchasenum;

    @ApiModelProperty(value = "折损")
    private String lossrate;

    @ApiModelProperty(value = "资产所在地")
    private String location;

    @ApiModelProperty(value = "购置时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date gmtCreate;

    public void copyFrom(Capital source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
